﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QqForm
{
    public class MessageLoginDeal : MessageDealBase
    {
        public override Object ShowMessage(TcpClass tcpClass, byte[] msg)
        {
            PostQqServerBackResult postQqServerBackResult = new PostQqServerBackResult();
            string cmdQq = Encoding.UTF8.GetString(msg, 0, msg.Length);
            if (cmdQq.IndexOf("VER", StringComparison.Ordinal) == -1)
            {
                return postQqServerBackResult;
            }
            string[] resultArrary = cmdQq.Split('&');
            List<string> listResult = new List<string>(resultArrary);
            if (!listResult.Contains("RES=0"))
            {
                postQqServerBackResult.IsSuc = false;
                postQqServerBackResult.Result = "请求服务器失败";
            }
            if (!listResult.Contains("RS=0"))
            {
                postQqServerBackResult.IsSuc = false;
                postQqServerBackResult.Result = listResult[listResult.Count - 1].Replace("RA=", "");
            }
            if (listResult.Contains("RS=0"))
            {
                postQqServerBackResult.IsSuc = true;
            }
            return postQqServerBackResult;
        }
    }
}
